<form class="layui-form seller-form" action="">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li><a href="{:url('homeList')}">服务费详情</a></li>
            <li class="layui-this"><a href="{:url('homeListTwo')}" >其他详情</a></li>
        </ul>
        <br />
        <div class="layui-inline">
            <input type="text" name="datetime" id="datetime" style="width: 200px;"
                   placeholder="start_time _ end_time" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="time">按输入时间更新</button>
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="all">更新全部</button>
            </div>
        </div>
        <div class="table-body">
            <table id="balanceTable" lay-filter="balanceTable"></table>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            //totalRow: true,
            method: 'post',
            url: "{:url('Toolbar/homeListTwo')}",
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { align: 'center', title: '统计时间',width:170,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'data',  align: 'center', title: 'Type',width: 200},
                {field: 'total_refund_amount', title: 'Comdata-Credit', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'total_refund_amount_un', title: 'Comdata-Credit-未退款', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'total_refund_amount_556766', title: 'Comdata-Credit-556766', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:190},
                {field: 'total_refund_amount_lss', title: 'Connexpay-credit', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'funding_amount_all', title: '充值金额', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'balance_com', title: 'Comdata-卡余额(总)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'balance_account_com', title: 'Comdata-卡限额(总)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'balance_lss', title: 'Connexpay-卡余额(总)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'balance_account_lss', title: 'Connexpay-卡限额(总)', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'cand_count_total', title: '卡数量(总)', align:"right",
                    style:'font-weight:bold' , width:180},
                {field: 'card_count_com', title: 'Comdata-卡数量', align:"right",
                    style:'font-weight:bold' , width:180},
                {field: 'card_count_lss', title: 'Connexpay-卡数量', align:"right",
                    style:'font-weight:bold' , width:180},
                {field: 'fund_admin', title: '管理员充值', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'fund_zfb', title: '支付宝充值', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'fund_zfb_sm', title: '支付宝扫码充值', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'fund_wx', title: '微信充值', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'fund_czm', title: '充值码充值', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'user_balance_total', title: '用户余额', align:"right",
                    style:'color:#FF5722;font-weight:bold' , width:180},
                {field: 'card_num_active_total', title: '激活-卡数量(总)', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_sus_total', title: '冻结-卡数量(总)', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_ter_total', title: '注销-卡数量(总)', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_active_com', title: 'Comdata-激活-卡数量', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_sus_com', title: 'Comdata-冻结-卡数量', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_ter_com', title: 'Comdata-注销-卡数量', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_active_lss', title: 'Connexpay-激活-卡数量', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_sus_lss', title: 'Connexpay-冻结-卡数量', align:"right",
                    style:'font-weight:bold' , width:200},
                {field: 'card_num_ter_lss', title: 'Connexpay-注销-卡数量', align:"right",
                    style:'font-weight:bold' , width:200}
            ]],
            page: true,
            limit: 20,
            limits: [20, 100, 1000,5000],
        });
        // form.on('submit(*)', function (data) {
        //     layui.table.reload('balanceTable', {
        //         where: data.field
        //         , page: {
        //             curr: 1 //重新从第 1 页开始
        //         }
        //     });
        //     return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        // });
        form.on('submit(time)', function (data) {
            const datetime = $("#datetime").val();
            if(datetime == ''){
                layer.msg('时间不能为空' , {time: 1500 , icon:2});
            }
            var loading =layer.load(1, {shade: [0.1,'#fff']});
            JsPost("{:url('homeUp')}", {datetime:datetime,is_all_up:0}, function(res){
                layer.close(loading);
                if(res.code >0){
                    layer.msg(res.msg, { time: 1500 , icon:1}, function () {
                        window.location.href = "{:url('homeListTwo')}";
                    });
                }else{
                    layer.msg(res.msg , {time: 1500 , icon:2});
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        form.on('submit(all)', function (data) {
            var loading =layer.load(1, {shade: [0.1,'#fff']});
            JsPost("{:url('homeUp')}", {is_all_up:1}, function(res){
                layer.close(loading);
                if(res.code >0){
                    layer.msg(res.msg, { time: 1500 , icon:1}, function () {
                        window.location.href = "{:url('homeListTwo')}";
                    });
                }else{
                    layer.msg(res.msg , {time: 1500 , icon:2});
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>